Skip to content

refactor CRD downloads#54

Open
gotwarlost wants to merge 3 commits intomainfrom
crds
Open

refactor CRD downloads#54
gotwarlost wants to merge 3 commits intomainfrom
crds

Conversation

@gotwarlost
Copy link
Copy Markdown
Collaborator

Currently this is a subcommand of the language server, which is weird because we don't expect the end user to directly download the language server binary and run commands.

This change does the following:

  • Removes the download code from the language server and removes the download-crds command
  • Adds an extract-crds command to fn-hcl-tools instead; this is something we ask the user to interact with
  • Changes the CRD source API definition type to remove the offline section. This is a breaking change but since we haven't released the language server....
  • Changes the CRD extraction logic to process provider and configuration objects to get image references rather than the old processing that required a manual image list. This is consistent with how crossplane validate does this.

Currently this is a subcommand of the language server, which is weird
because we don't expect the end user to directly download the language server
binary and run commands.

This change does the following:

* Removes the download code from the language server and removes the download-crds command
* Adds an extract-crds command to fn-hcl-tools instead; this is something we ask the user to interact with
* Changes the CRD source API definition type to remove the offline section.
  This is a breaking change but since we haven't released the language server....
* Changes the CRD extraction logic to process provider and configuration objects to get image references rather than the old processing that
  required a manual image list. This is consistent with how crossplane validate does this.

Signed-off-by: gotwarlost <krishnan.anantheswaran@elastic.co>
Signed-off-by: gotwarlost <krishnan.anantheswaran@elastic.co>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR moves CRD download/extraction responsibilities out of the language server and into fn-hcl-tools, aligning user-facing workflows with the right binary while simplifying the LS runtime schema-loading model.

Changes:

  • Added a new internal/crds extraction pipeline (YAML filtering + image discovery + xpkg image pulling) and a new fn-hcl-tools extract-crds command.
  • Removed the download-crds language-server subcommand and the associated caching/downloading implementation.
  • Simplified the CRD source API to remove the offline/runtime split (breaking schema change) and updated LS CRD source store usage accordingly.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
function-hcl/internal/crds/api.go Defines CRD extraction API types (Image/ObjectMetadata/Writer/Extractor).
function-hcl/internal/crds/extractor.go Implements YAML scanning, image reference discovery, and remote package.yaml extraction.
function-hcl/internal/crds/writer.go Adds writer implementations for streaming output and file splitting.
function-hcl/internal/crds/misc-writers.go Adds progress/warning/multi-writer helpers.
function-hcl/cmd/fn-hcl-tools/extract-crds.go Adds the new extract-crds CLI command and wiring to the extractor/writers.
function-hcl/cmd/fn-hcl-tools/main.go Registers the new extract-crds command.
function-hcl/go.mod Adds new dependencies (container registry, globbing) and bumps various versions.
function-hcl/go.sum Updates sums for dependency changes.
function-hcl-ls/types/v1/crd-source.go Removes offline/runtime config sections from the CRD source type.
function-hcl-ls/internal/features/crds/store/store.go Updates CRD source loading to use the simplified CRD source type.
function-hcl-ls/internal/features/crds/store/source-store.go Updates sourceInfo to store *types.CRDSource instead of runtime-only type.
function-hcl-ls/main.go Removes registration of the download-crds command.
function-hcl-ls/internal/features/crds/api.go Removes exported Download API.
function-hcl-ls/internal/features/crds/cache.go Deletes legacy image download/cache implementation.
function-hcl-ls/internal/cmd/download-crds.go Deletes the download-crds command implementation.
function-hcl-ls/mise.toml Removes mise tool config from LS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…lobs

Signed-off-by: gotwarlost <krishnan.anantheswaran@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants